/**
 * 判断访问类型是电脑还是手机
 * @author zqtao
 * @git https://gitee.com/zqtao23/
 */
$(function () {
    const mobile_flag = isMobile(); // true为手机端，false为pc端

    if (mobile_flag) {
        // 适应手机样式，替换PC端样式
        $("#export_content").css({"width": "95%", "margin": "20px auto"});

        // 隐藏侧边栏
        $(".leftNav-item").css({"display": "none"});
    }
});

function isMobile() {
    const userAgentInfo = navigator.userAgent;

    const mobileAgents = ["Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod"];

    let mobile_flag = false;

    //根据userAgent判断是否是手机
    for (let v = 0; v < mobileAgents.length; v++) {
        if (userAgentInfo.indexOf(mobileAgents[v]) > 0) {
            mobile_flag = true;
            break;
        }
    }

    const screen_width = window.screen.width;
    const screen_height = window.screen.height;

    //根据屏幕分辨率判断是否是手机
    if (screen_width < 500 && screen_height < 800) {
        mobile_flag = true;
    }
    return mobile_flag;
}
